<template>
  <div id="app">
    <table class="tb">
      <tr>
        <th>欢迎光临vue开发的收银水果系统</th>
      </tr>
      <tr>
        <td>苹果 10 ￥ / 斤 折扣 （8折）</td>
      </tr>
      <tr>
        <td>请输入购买的斤数 <input type="text" v-model.number="num"/></td>
      </tr>
      <tr>
        <td><button @click="btn">结算买单</button></td>
      </tr>
      <tr>
        <td>结账单：总价：{{num1}} ￥元 折后价:{{num2}}￥元 节省了：{{num3}}￥元</td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
    data() {
        return {
            num:'',
            num1:0,
            num2:0,
            num3:0,
        }
    },
    methods:{
        btn(){
            // console.log(1)
        this.num1 = this.num*10   
        this.num2 = this.num*8
        this.num3 = this.num*(this.num1-this.num2)    
        },
       
    }
};
</script>

<style>
#app {
  width: 600px;
  margin: 10px auto;
}

.tb {
  border-collapse: collapse;
  width: 100%;
}

.tb th {
  background-color: #0094ff;
  color: white;
}

.tb td,
.tb th {
  padding: 5px;
  border: 1px solid black;
  text-align: center;
}

.add {
  padding: 5px;
  border: 1px solid black;
  margin-bottom: 10px;
}
</style>